import modules from './modules'
// 视图组件
const view = {
  tabs: () => import('@/layouts/tabs'),
  blank: () => import('@/layouts/BlankView'),
  page: () => import('@/layouts/PageView')
}
// 初始化路由map
function initRouterMap(modules){
  let routerMap = {}
  for (let key in modules) {
    routerMap = Object.assign(routerMap, modules[key])
  }
  return routerMap
}
// 路由组件注册
const routerMap = Object.assign({
  login: {
    authority: '*',
    path: '/login',
    component: () => import('@/pages/login')
  },
  root: {
    path: '/',
    name: '首页',
    redirect: '/login',
    component: view.tabs
  },
  exp404: {
    path: '*',
    name: '404',
    component: () => import('@/pages/exception/404')
  },
  exp403: {
    path: '/403',
    name: '403',
    component: () => import('@/pages/exception/403')
  },
  dashboard: {
    name: 'Dashboard',
    icon: 'dashboard',
    component: view.blank
  },
  workplace: {
    name: '工作台',
    component: () => import('@/pages/map/index')
  },
  analysis: {
    name: '分析页',
    component: () => import('@/pages/dashboard/analysis')
  }
}, initRouterMap(modules))
export default routerMap
